package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * 简易记事本
 */
public class PwDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos = new FileOutputStream("note.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw,true);//加true有自动按还能赶上修女功能

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入内容，输入exit离开");
        while(true){
            String str = scan.nextLine();
            if ("exit".equalsIgnoreCase(str)){
                break;
            }
            pw.println(str);
        }
        System.out.println("再见");
        pw.close();

    }
}
